const trackLoadPageAction = (pageActionName) => { if (window.newrelic) { const data = { channel: window.upaData.ch, flow: window.upaData.fl, ltype: window.upaData.ltype, lname: window.upaData.lname, pageviewId: window.upaData.pageview_id, userAgent: navigator.userAgent, } try { window.newrelic.addPageAction(pageActionName, data); } catch (e) { } } } const trackLandingContext = () => { if (window?.landingContext) { try { const _TIMEOUT = 1500; const xhr = new XMLHttpRequest(); xhr.open("POST", `${document.location.origin}/nymeria-api/landingContext`, true); xhr.timeout = _TIMEOUT; xhr.setRequestHeader("Accept", "application/json"); xhr.setRequestHeader("Content-Type", "application/json"); xhr.setRequestHeader("requesturl", document.location.href); xhr.send(JSON.stringify(window.landingContext)); } catch (e) { throw new Error("Ajax post error"); } } } const trackLandingVisit = () => { if (!document.location.host.includes('desa.')) { const data = { ltype: window.upaData.ltype, lname: window.upaData.lname, path: window.location.pathname, lang: window.upaData.lan, country: window.upaData.cc, partner_id: window.upaData.partner_id } try { const _TIMEOUT = 1500; const xhr = new XMLHttpRequest(); xhr.open("POST", `${document.location.origin}/nymeria-api/landingVisit`, true); xhr.timeout = _TIMEOUT; xhr.setRequestHeader("Accept", "application/json"); xhr.setRequestHeader("Content-Type", "application/json"); xhr.setRequestHeader("requesturl", document.location.href); xhr.send(JSON.stringify(data)); } catch (e) { throw new Error("Ajax post error"); } } } window.isPageLoaded = false; window.addEventListener('load', () => { window.isPageLoaded = true; trackLandingVisit(); trackLandingContext(); trackLoadPageAction('nymeriaGuiLoad'); }); window.onbeforeunload = () => { if (!isPageLoaded) { trackLoadPageAction('nymeriaGuiLoadError'); } };